package com.wz.project.bas.ProductConfig.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.bas.ProductConfig.domain.ProductConfig;
import com.wz.project.bas.ProductConfig.service.IProductConfigService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 销售排行等级Controller
 * 
 * @author wz
 * @date 2024-01-15
 */
@Controller
@RequestMapping("/bas/ProductConfig")
public class ProductConfigController extends BaseController
{
    private String prefix = "bas/ProductConfig";

    @Autowired
    private IProductConfigService productConfigService;


    @GetMapping()
    public String ProductConfig()
    {
        return prefix + "/ProductConfig";
    }

    /**
     * 查询销售排行等级列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProductConfig productConfig)
    {
        startPage();
        List<ProductConfig> list = productConfigService.selectProductConfigList(productConfig);
        return getDataTable(list);
    }

    /**
     * 导出销售排行等级列表
     */
    @Log(title = "销售排行等级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ProductConfig productConfig)
    {
        List<ProductConfig> list = productConfigService.selectProductConfigList(productConfig);
        ExcelUtil<ProductConfig> util = new ExcelUtil<ProductConfig>(ProductConfig.class);
        return util.exportExcel(list, "ProductConfig");
    }

    /**
     * 新增销售排行等级
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存销售排行等级
     */
    @Log(title = "销售排行等级", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ProductConfig productConfig)
    {
        return toAjax(productConfigService.insertProductConfig(productConfig));
    }

    /**
     * 修改销售排行等级
     */
    @GetMapping("/edit/{productPriority}")
    public String edit(@PathVariable("productPriority") String productPriority, ModelMap mmap)
    {
        ProductConfig productConfig = productConfigService.selectProductConfigById(productPriority);
        mmap.put("productConfig", productConfig);
        return prefix + "/edit";
    }

    /**
     * 修改保存销售排行等级
     */
    @Log(title = "销售排行等级", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ProductConfig productConfig)
    {
        return toAjax(productConfigService.updateProductConfig(productConfig));
    }

    /**
     * 删除销售排行等级
     */
    @Log(title = "销售排行等级", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(productConfigService.deleteProductConfigByIds(ids));
    }
}
